	<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page import="Logic.Authorizer"%>
	<%@ page import="java.sql.*" %>
	<%@ page import="java.io.*" %> 
	<%@ page import="java.util.*"%>
<!DOCTYPE html>
<style>
input[type=text],[type=file]{
    margin-left:2%;
}
fieldset{
    margin:1%;
}
</style>
<%
	if (session.getAttribute("name") == null) {
		response.sendRedirect("login.jsp");
	} else {
		if (!Authorizer.checkRole("2", session.getAttribute("role")
				.toString())) {
			response.sendRedirect("nopermission.jsp");
		}
	}
%>
<jsp:include page="t_header.jsp" />

<!--  <div class="breadcrumbs_container">
	<article class="breadcrumbs"> <a href="QM_NewDeviationNotes.jsp">Manage Quality
		Manual</a>
	<div class="breadcrumb_divider"></div>
	<a class="current">New Deviation Notes</a> 
	</article>
</div> -->
<jsp:include page="header.html" />

<!-- Declare sidebar -->
<jsp:include page="t_sidebartry.jsp" />

<!-- Main Content -->
<body>
	<section id="main" class="column">
	<article class="module width_3_quarter">
	<form id="SingleDNote" action="SingleDNote.jsp" method="post" enctype="multipart/form-data">
	<header><h3>Create New Deviation Note</h3></header>
	<div class="module_content">
	<fieldset>
	<label>Deviation Note Name</label>
	<input type='text' id="DNoteName" name="DNoteName" style="width: 80%;" onChange="CheckProcess(this.value, this)">
	</fieldset>
	<fieldset>
	<label>Document</label>
	<div style="width: auto; margin: 0 auto;">
	<input id="file" type="file" name="file" style="width: 85%; "/>
	</div>
	</fieldset>
	</div>
    <footer>
    <div class="submit_link">
    <input id="Update" type="submit" value="Add" onclick="return verifyData()" class="alt_btn"/>
    <input id="Clear" type="reset" value="Clear" onclick="Clear()" class="alt_btn">
    </div>
    </footer>
    </form>
    </article>
    
<script type="text/javascript">
function verifyData(){
if(CheckSpecial()==false)
{
	alert('Please ensure that all entered text does not contain special characters. ');
	return false;
}
else{
     if ( $('#file').val() == ""||$('#DNoteName').val() == "") {
          alert('Please ensure that all fields are filled in and document is selected.');
 		  return false;
     }
     else {
    	 alert('File selected: ' + $('#file').val());
			var form = document.getElementById('SingleDNote');		  
			var NameVar=document.getElementById('DNoteName').value;
			form.action="SingleDNote.jsp?DNoteName="+NameVar;
     		form.submit();
     	  
  		return true;     
     }
   }
}
function Clear(){
document.getElementById('SingleDNote').reset();	
return false;
}

function CheckProcess(str, object)
{
    var iChars = "~`!#$%^*+=[]\\\';,/{}|\":<>?";
	object.style.backgroundColor="#FFF";
    for (var i = 0; i < str.length; i++) {
       if (iChars.indexOf(str.charAt(i)) != -1) {
	       object.style.backgroundColor="#FA5858";
           alert ("Special characters like ~`!#$%^*+=[]\\\';,/{}|\":<>? \nare not allowed!\n");
           object.focus();
           object.select();
 		   break;
       }
    }
}

function CheckSpecial()
{
var iChars = "~`!#$%^*+=[]\\\';,/{}|\":<>?";
var DNoteNameObj=document.getElementById('DNoteName').value;

var result=true;
    for (var i = 0; i < DNoteNameObj.length; i++) {
       if (iChars.indexOf(DNoteNameObj.charAt(i)) != -1) {
	      result=false;
	      break;
       }
       
    }
    return result;
}
</script>
<div class="spacer"></div>
</section>
</body>



